home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 2.9 KB | 120 lines | [TEXT/ToyS] |
- (*
- Watches the free space on volumes in an info window
-
- Applet(StayOpen, NoDialog)
- *)
-
- -- Preferences
- property kasPrefName : "Disks & Drivers V1.1"
- property kasColors : {15, 15 * 32, 15 * 1024}
- property kasFontName : "Monaco"
- property kasFontSize : 10
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasLastVolCnt -- Last volume count
-
-
- on run
- pfLoad()
- set gasLastVolCnt to 0
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos
- end run
-
-
- on idle
- display info gasInfoWind message "••• SCANNING •••" at line gasLastVolCnt
-
- set volCnt to 0
- set volIdx to 1
-
- repeat while true
- try
- set vInfo to the volume info of volume index volIdx
- on error
- exit repeat
- end try
-
- set volCnt to volIdx
- set infoPos to DisplayLine(vInfo, volIdx)
- set volIdx to volIdx + 1
- end repeat
-
- -- Invalidate removed volume?
- if (volCnt < gasLastVolCnt) then
- repeat with n from volCnt to (gasLastVolCnt - 1)
- display info gasInfoWind message "…" at line n
- end repeat
- end if
-
- set gasLastVolCnt to volCnt
-
- -- Save Screen Location of info window if changed
- if (infoPos is not gasInfoPos) then
- set gasInfoPos to infoPos
- pfSave()
- end if
-
- return 60
- end idle
-
-
- on DisplayLine(info, lineNum)
- set freeBytes to ((vol block size of info) * (vol free blocks of info))
- set pctFull to recompose ((vol free blocks of info) / (vol total blocks of info)) with percentage
-
- set myCol to item 1 of kasColors
- if (vol kind of info is AFP volume) then set myCol to item 2 of kasColors
- if (vol read only of info is true) then set myCol to item 3 of kasColors
-
- if (pctFull < 10) then set myCol to myCol + (15 * 1024)
-
- if (vol removable of info) then
- set myLine to "*"
- else
- set myLine to " "
- end if
-
- if (vol kind of info is HFS plus volume) then
- set myLine to myLine & "+ "
- else
- set myLine to myLine & " "
- end if
-
- set myLine to myLine & (recompose (vol ref of info) padded to 3)
- set myLine to myLine & (recompose (vol name of info) padded to 28)
- set myLine to myLine & (recompose pctFull padded to -8)
- set myLine to myLine & (recompose freeBytes padded to -10 with kilomegs)
- set myLine to myLine & (recompose (vol driver ref of info) padded to -4)
-
- set myLine to myLine & (recompose ((vol block size of info) * (vol total blocks of info)) padded to -10 with kilomegs)
- set myLine to myLine & " " & (vol driver name of info)
-
- return screen location of ¬
- (display info gasInfoWind ¬
- message myLine ¬
- at line lineNum ¬
- using font kasFontName ¬
- using size kasFontSize ¬
- using color myCol ¬
- with a change of style and static state)
- end DisplayLine
-
-
- on pfLoad()
- try
- set ourPrefs to load preference named kasPrefName
- on error
- set ourPrefs to {pfWLoc:{40, 64}}
- end try
-
- set gasInfoPos to pfWLoc of ourPrefs
- end pfLoad
-
-
- on pfSave()
- save preference {pfWLoc:gasInfoPos} named kasPrefName
- end pfSave
-